package com.rqf.mr.controller;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.rqf.mr.service.ICostService;
import com.server.web.JSONSerielizer;
import com.server.web.OutputUtil;


/**
 * 登录相关
 * @author HelloWorld_luo
 * @date 2016年4月18日
 */
@Controller
@RequestMapping("cost")
public class CostController {
	
	@Autowired
	private ICostService costService;
	
	@RequestMapping("allcost/{serialnumber}")
	public void allcost(HttpServletRequest request, 
			HttpServletResponse response,@PathVariable String serialnumber){
		if (StringUtils.isEmpty(serialnumber)) {
			
		}
		List<Map<String, Object>> list = costService.searchAllCostInfo(serialnumber);
		String json = JSONSerielizer.toJson(list, null, null);
		OutputUtil.returnJsonp(request, response, json);
	} 
	
	@RequestMapping("detailcost/{serialnumber}")
	public void detailcost(HttpServletRequest request, 
			HttpServletResponse response,@PathVariable String serialnumber){
		if (StringUtils.isEmpty(serialnumber)) {
			
		}
		List<Map<String, Object>> list = costService.searchDetailCostInfo(serialnumber);
		String json = JSONSerielizer.toJson(list, null, null);
		OutputUtil.returnJsonp(request, response, json);
	} 
	
	@RequestMapping("watercost/{serialnumber}")
	public void login(HttpServletRequest request, 
			HttpServletResponse response,@PathVariable String serialnumber){
		if (StringUtils.isEmpty(serialnumber)) {
			
		}
		List<Map<String, Object>> list = costService.searchRunningWaterCostInfo(serialnumber);
		String json = JSONSerielizer.toJson(list, null, null);
		OutputUtil.returnJsonp(request, response, json);
	} 
}
